const { ADS } = require("./ads/ADS");
const { videoAds } = require("./ads/video");
const { show, msg } = require("./game/alert");
const { player, achieveProcess } = require("./shop/gameData");

cc.Class({
    extends: cc.Component,

    properties: {
        playerName:cc.Label,
        money:cc.Label,
        joinCount:cc.Label,
        selfCount:cc.Label,
        income:cc.Label,
        storeCount:cc.Label,
        addMoney:cc.Sprite
    },

    // LIFE-CYCLE CALLBACKS:

    onEnable () {
        this.money.string = "金钱:"+player.money;
        this.playerName.string =  cc.sys.localStorage.getItem('shopName')||shopName;
    },

    start () {
        
    },
    addMoneyByAds () {
        videoAds.showAd(data => {
            if(data) {
                player.money += 10000;
                this.money.string = "金钱："+player.money;
                msg('获得融资1w元');
                achieveProcess.ad ++;
            }
        })
    },
    earn (target,money) {
        //赚钱的函数
        player.money+=100;
    },
    update (dt) {
        this.money.string="金钱:"+formatMoney(player.money);
    },
});
